<template>
  <page-layout>
    <a-row :gutter="[10, 10]">
      <a-col :span="24">
        <a-card title="详情">
          <template #extra>
            <a-button type="primary" class="ml-5" @click="edit(baseFields.id)">编辑</a-button>
          </template>
          <a-row>
            <a-col :span="4">
              <a-avatar :size="64" :src="baseFields.data.professorPicture"></a-avatar>
            </a-col>
            <a-col :span="20">
              <a-row>
                <a-col :span="8">
                  <a-form-item>教授编码：{{baseFields.data.code}}</a-form-item>
                </a-col>
                <a-col :span="8">
                  <a-form-item>教授姓名：{{baseFields.data.name}}</a-form-item>
                </a-col>
                <a-col :span="8">
                  <a-form-item>任职学校：{{baseFields.data.serviceSchoolName}}</a-form-item>
                </a-col>
                <!-- <a-col :span="8">
                  <a-form-item>综合评分：***</a-form-item>
                </a-col> -->
                <a-col :span="8">
                  <a-form-item>收款银行：{{baseFields.data.collectionBank}}</a-form-item>
                </a-col>
                <a-col :span="8">
                  <a-form-item>收款账号：{{baseFields.data.collectionAccount}}</a-form-item>
                </a-col>
                <a-col :span="8">
                  <a-form-item>创建人：{{baseFields.data.createTime}}</a-form-item>
                </a-col>
                <a-col :span="8">
                  <a-form-item>创建时间：{{baseFields.data.createBy}}</a-form-item>
                </a-col>
                <a-col :span="8">
                  <a-form-item>简介：{{baseFields.data.briefIntroduction}}</a-form-item>
                </a-col>
              </a-row>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="24">
        <a-card title="基本信息">
          <a-row>
            <a-col :span="8">
              <a-form-item>姓：{{baseFields.data.surname}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>名：{{baseFields.data.firstName}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>中间字：{{baseFields.data.middleInitial}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>身份证号码：{{baseFields.data.idCar}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>申请日期：{{baseFields.data.applicationDate}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>状态：{{baseFields.data.applicationDate}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>入职日期：{{baseFields.data.hireDate}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>教员组:{{baseFields.data.facultyGroup}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>alt邮件:{{baseFields.data.altEmail}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>街道地址:{{baseFields.data.streetAddress}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>详细地址:{{baseFields.data.addressLine2}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>城市:{{baseFields.data.city}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>州/省:{{baseFields.data.stateProvince}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>邮政编码:{{baseFields.data.zipPostalCode}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>国家:{{baseFields.data.country}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>公民身份:{{baseFields.data.citizenship}}</a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item>电话号码:{{baseFields.data.phoneNumbe}}</a-form-item>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="24">
        <a-card title="工作经验">
          <a-row>
            <a-col :span="24">
              <a-form-item>授权在美国工作？</a-form-item>
              <a-form-item>{{baseFields.data.authorizedWorkYesno}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>以前为莱恩教育工作过吗？</a-form-item>
              <a-form-item>{{baseFields.data.previouslyWorkYesno}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>简要描述您在莱恩教育工作的时间和身份.</a-form-item>
              <a-form-item>{{baseFields.data.capacityDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>开始供应日期</a-form-item>
              <a-form-item>{{baseFields.data.startingAvailabilityDate}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>最后可用日期（如果与您申请的职位相关）</a-form-item>
              <a-form-item>{{baseFields.data.lastAvailabilityDate}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>申请职位</a-form-item>
              <a-form-item>{{baseFields.data.applyingPosition}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>你有教国际学生的经验吗？</a-form-item>
              <a-form-item>{{baseFields.data.teachingInternationalYesno}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>简要描述你教国际学生的经历.</a-form-item>
              <a-form-item>{{baseFields.data.teachingInternational}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>你有在中国教书的经验吗？</a-form-item>
              <a-form-item>{{baseFields.data.acceleratedYesno}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>简要描述你在中国的教学经验.</a-form-item>
              <a-form-item>{{baseFields.data.chinaExprienceDescribe}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>你有在其他国家教书的经验吗？</a-form-item>
              <a-form-item>{{baseFields.data.otherforeignExperienceDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>如果你的答案与你教国际学生的经验相同，请注明。否则，请简要描述您在任何其他国家的教学经验.</a-form-item>
              <a-form-item>{{baseFields.data.otherforeignExperienceDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>你是否有以速成形式教授课程的经验？</a-form-item>
              <a-form-item>{{baseFields.data.acceleratedYesno}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>简要描述您在加速课程教学中的经验.</a-form-item>
              <a-form-item>{{baseFields.data.acceleratedDesc}}</a-form-item>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="24">
        <a-card title="教育背景">
          <a-row>
            <a-col :span="24">
              <a-form-item>最高教育水平</a-form-item>
              <a-form-item>{{baseFields.data.highestLevelEducation}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>最高学历证书名称</a-form-item>
              <a-form-item>{{baseFields.data.credentialHighest}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>最高教育水平的学科/领域</a-form-item>
              <a-form-item>{{baseFields.data.disiplineHighest}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>第一个附加凭证的类型</a-form-item>
              <a-form-item>{{baseFields.data.additionalCredentialDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>颁发第一个附加证书的机构</a-form-item>
              <a-form-item>{{baseFields.data.addirionalCredentialDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>第一个附加凭证的标题</a-form-item>
              <a-form-item>{{baseFields.data.additionalCredentialTitle}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>第一个附加凭证的学科/领域</a-form-item>
              <a-form-item>{{baseFields.data.additionalCredentialDiscipline}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>第二个附加凭证的类型</a-form-item>
              <a-form-item>{{baseFields.data.secondAdditionalCredentialTypedesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>颁发第二个附加证书的机构</a-form-item>
              <a-form-item>{{baseFields.data.secondAdditionalCredentialDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>第二个附加凭证的标题</a-form-item>
              <a-form-item>{{baseFields.data.econdAdditionalCredentialTitle}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>第二个附加凭证的学科/领域</a-form-item>
              <a-form-item>{{baseFields.data.econdCredentialDiscipline}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>授权莱恩联系主管</a-form-item>
              <a-form-item>{{baseFields.data.authonrizedSupervisorsLion}}</a-form-item>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="24" v-if="baseFields.professorEmploymentBackgroud.length>0">
        <a-card title="就业背景">
          <a-row v-for="(item,index) in baseFields.professorEmploymentBackgroud" :key="index" class="Employment">
            <a-col :span="24">
              <!-- 雇员 -->
              <a-form-item>雇员</a-form-item>
              <a-form-item>{{item.empoyer}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 雇员地址 -->
              <a-form-item>雇员地址</a-form-item>
              <a-form-item>{{item.empoyerLocation}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 员工电话号码 -->
              <a-form-item>雇员电话号码</a-form-item>
              <a-form-item>{{item.empoyerPhoneNumber}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 职位名称 -->
              <a-form-item>职位名称</a-form-item>
              <a-form-item>{{item.jobTitle}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 工作职责和成就 -->
              <a-form-item>工作职责和成就</a-form-item>
              <a-form-item>{{item.jobResponsibilities}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 开始受雇日期 -->
              <a-form-item>开始受雇日期</a-form-item>
              <a-form-item>{{item.startdateEmployment}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- Currently employed by this employer -->
              <a-form-item>目前受雇于该雇主？</a-form-item>
              <a-form-item>{{item.currentlyEmployed}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 终止受雇日期 -->
              <a-form-item>终止受雇日期</a-form-item>
              <a-form-item>{{item.enddateEmployment}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 主管姓名和职务 -->
              <a-form-item>主管-职务</a-form-item>
              <a-form-item>{{item.supervisorName}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 主管姓名-全名 -->
              <a-form-item>主管姓名-全名</a-form-item>
              <a-form-item>{{item.supervisorFullname}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 主管名称参考-组织 -->
              <a-form-item>主管-组织</a-form-item>
              <a-form-item>{{item.supervisorOrganization}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 主管姓名参考-与您的关系 -->
              <a-form-item>主管-与您的关系</a-form-item>
              <a-form-item>{{item.supervisorOrganizationRelationship}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 主管姓名参考-电子邮件地址 -->
              <a-form-item>主管-电子邮件</a-form-item>
              <a-form-item>{{item.supervisorAddress}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <!-- 主管姓名参考-电话号码（包括国际代码） -->
              <a-form-item>主管-电话号码（包括国际代码）</a-form-item>
              <a-form-item>{{item.supervisorPhone}}</a-form-item>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="24">
        <a-card title="其他">
          <a-row>
            <a-col :span="24">
              <a-form-item>非拉丁字母的名称（例如，对于中文名称，请在此处输入中文字符）</a-form-item>
              <a-form-item>{{baseFields.data.nonLationDesc}}</a-form-item>
            </a-col>
            <a-col :span="24">
              <a-form-item>以前在莱恩一起教授的课程</a-form-item>
              <a-form-item>{{baseFields.data.coursesPreviouslyLion}}</a-form-item>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
    </a-row>
  </page-layout>
</template>
<script>
  import {
    defineComponent,
    reactive,
    toRaw,
    createVNode,
    onMounted,
    ref,
    onActivated
  } from "vue";
  import {
    useRoute,
    useRouter
  } from 'vue-router';
  import {
    selectById
  } from "@/api/module/professor";
  import {
    message
  } from 'ant-design-vue';
  import moment from 'moment'
  import {
    getDictByCodesReturnObj
  } from '@/tools/get-dict'
  import {
    isEmpty
  } from '@/tools/common'
  import dictEnum from "@/const/dict"
  import { useI18n } from "vue-i18n";
  export default defineComponent({
    name: 'professor-manage-detail',
    setup() {
      const  { t } = useI18n();
      const router = useRouter();
      const route = useRoute();
      const baseFields = reactive({
        data: {},
        id: '',
        professorEmploymentBackgroud: [],
        dict: {}
      })
      const getDataByDict = (data, dictKey) => {
        if (isEmpty(data)) return '-'
        const item = baseFields.dict[dictKey].find(v => v.value == data)
        if (isEmpty(item)) return '-'
        return item.label
      }
      onActivated(async () => {
        baseFields.dict = await getDictByCodesReturnObj([
          dictEnum.YES_OR_NO
        ])

        let res = await selectById({
          id: route.query.id
        })
        if (res.code === 500) return message.error('获取详情失败')
        res.data.acceleratedYesno = getDataByDict(res.data.acceleratedYesno, dictEnum.YES_OR_NO)
        res.data.authorizedWorkYesno = getDataByDict(res.data.authorizedWorkYesno, dictEnum.YES_OR_NO)
        res.data.otherforeignExperienceYesno = getDataByDict(res.data.otherforeignExperienceYesno, dictEnum
          .YES_OR_NO)
        res.data.previouslyWorkYesno = getDataByDict(res.data.previouslyWorkYesno, dictEnum.YES_OR_NO)
        res.data.teachingInternationalYesno = getDataByDict(res.data.teachingInternationalYesno, dictEnum
          .YES_OR_NO)
        res.data.applicationDate = moment(res.data.applicationDate).format('YYYY-MM-DD')
        res.data.startingAvailabilityDate = moment(res.data.startingAvailabilityDate).format('YYYY-MM-DD')
        res.data.lastAvailabilityDate = moment(res.data.lastAvailabilityDate).format('YYYY-MM-DD')
        for (var i in res.data.professorEmploymentBackgroud) {
          res.data.professorEmploymentBackgroud[i].currentlyEmployed = getDataByDict(res.data
            .professorEmploymentBackgroud[i].currentlyEmployed, dictEnum.YES_OR_NO)
          res.data.professorEmploymentBackgroud[i].startdateEmployment = moment(res.data
            .professorEmploymentBackgroud[i].startdateEmployment).format('YYYY-MM-DD')
          res.data.professorEmploymentBackgroud[i].enddateEmployment = moment(res.data
            .professorEmploymentBackgroud[i].enddateEmployment).format('YYYY-MM-DD')
        }
        baseFields.id = route.query.id;
        baseFields.data = res.data;
        baseFields.professorEmploymentBackgroud = res.data.professorEmploymentBackgroud;
      })
      const edit = (msg) => {
        router.push('/university/professor-manage/add?id=' + msg)
      }
      return {
        baseFields,
        edit,
      }
    }
  })
</script>
<style scoped>
  .ant-form-item {
    margin-bottom: 0x;
    margin: 10px 0;
  }

  .Employment {
    padding: 10px;
  }

  .Employment:nth-child(even) {
    background-color: #F0F2F5;
  }
</style>
